<%@page import="common.Var"%>
<%@page import="java.util.List"%>
<%@page import="com.ks.entity.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>展示所有用户</title>
</head>
<body>
	<%
		List<User> userList = (List<User>) request.getAttribute(Var.USERLIST_INFO);
		if (userList == null) {
			out.print("userList为null" + userList);

		} else {
			System.out.print(userList.size());
		}
	%>
	<h1>All Users:</h1>
	<br>
	<table width="200" border="1">
		<tbody>
			<tr>
				<td>&nbsp;用户名</td>
				<td>&nbsp;年龄</td>
				<td>&nbsp;地址</td>
				<td>&nbsp;头像</td>
				<td>&nbsp;操作</td>
			</tr>
			<%
				for (User user : userList) {
			%>
			<tr>
				<td><%=user.getUsername()%></td>
				<td><%=user.getAge()%></td>
				<td><%=user.getAddress()%></td>
				<td><%=user.getImg()%></td>
				<td><a
					href="/userServlet?method=deleteUser&username=<%=user.getUsername()%>">删除</a></td>
			</tr>
			<%
				}
			%>
		</tbody>
	</table>
	<br> 所有用户列表(使用EL和JSTL):
	<br>
	<table width="200" border="1">
		<tbody>
			<tr>
				<td>&nbsp;用户名</td>
				<td>&nbsp;年龄</td>
				<td>&nbsp;地址</td>
				<td>&nbsp;头像</td>
				<td>&nbsp;操作</td>

			</tr>
			<c:forEach items="${requestScope[Var.USERLIST_INFO]}" var="user">
				<tr>
					<td>${user.username}</td>
					<td>${user.age}</td>
					<td>${user.address}</td>
					<td>${user.img}</td>
					<td><a
						href="/userServlet?method=deleteUser&username=${user.username}">删除</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<br>


	<h3>
		<a href="/jsp/welcome.jsp">返回</a>
	</h3>
</body>
</html>